<?php
/**
 * XmuSlh, web platform of Student Association Federation of Xiamen University
 * 
 * Rewritting one or some pages of StatusNet. 
 * To get the original version, please visit <http://status.net/>.
 * 
 * StatusNet, the distributed open-source microblogging tool
 * 
 * LICENCE: This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * Base class for UI widgets
 * 
 * A widget is a cluster of HTML elements that provide some functionality
 * that's used on different parts of the site. Examples would be profle
 * lists, notice lists, navigation menus (tabsets) and common forms.
 * 
 * 例如: 这是Form的一个基类, 一个Form是在HTML页面中区别其他部分显示的一个部分, 可以是一个
 * 单独的提交数据的部分, 使用AJAX?
 * 
 * @author		ytukie <ytukie@gmail.com>
 * @version		0.2
 * 
 * 0.2)  Adds the 'args' field, and 'getField' function.
 */

// XmuSlh only.
if ( !defined('XMUSLH')) { exit(1); }

class Widget
{
	/**
	 * HTMLOutputter to use for output
	 */
	var $out = null;
	
	/**
	 * Is the $out an action object. If so, we could get the arguments.
	 */
	var $args = array();
	
	function __construct($out, &$args = array())
	{
		$this->args =& $args;
		$this->out = $out;
	}
	
	/**
	 * Show the widget
	 * 
	 * Emit the HTML for the widget, using the configured outputter.
	 * Need to be overrided.
	 */
	function show()
	{
	}
	
	/**
	 * Get the args of the fields.
	 * 
	 * @return A string object if not null, else null.
	 */
	function getField($id)
	{
		if (array_key_exists($id, $this->args)) {
			return $this->args[$id];
		}
		
		return null;
	}
}